<template>
	<view class="my-content">
		<view class="my-head">
			<view>
				<image :src="userInfo.avatar" mode=""></image>
			</view>
			<view class="my-head-user">
				<view>{{userInfo.nickName}}</view>
				<view>{{userInfo.vipLevel}}</view>
			</view>
			<view @click="toPersonal">
				<uni-icons type="forward" size=20></uni-icons>
			</view>
		</view>
		<view class="tab-scend">
			<uni-badge v-for="(item,index) in tabScend" :text="item.num" type="error" absolute="rightTop" :key="index">
				<view class="item-box" @click="goPage(index)">
					<image :src="item.item[0].icon" mode="" v-show="item.item[0].icon!=''"></image>
					<text>{{item.item[0].text}}</text>
					<view>{{item.title}}</view>
				</view>
			</uni-badge>
		</view>
		<view class="finally-tab">
			<uni-badge v-for="(item,index) in finallyTab" :text="item.num" type="error" absolute="rightTop"
				:key="index">
				<view class="item-box finitem" @click="gotoPage(index)">
					<image :src="item.icon" mode=""></image>
					<view>{{item.title}}</view>
				</view>
			</uni-badge>
		</view>
	</view>
</template>

<script>
	import {
		reactive,
		toRefs
	} from 'vue';
	import store from '../../store/index.js';
	import { onShow,onLoad } from '@dcloudio/uni-app'
	export default {
		setup() {
			let data = reactive({
				code: '',
				tabScend: [{
					title: '团课',
					item: [{
						icon: '../../static/my/金币商城.png',
						text: ''
					}],
					num: '10'
				}, {
					title: '私教',
					item: [{
						icon: '../../static/my/金币商城.png',
						text: ''
					}],
					num: '10'
				}, {
					title: '消息',
					item: [{
						icon: '../../static/my/金币商城.png',
						text: ''
					}],
					num: '10'
				}, {
					title: '评论',
					item: [{
						icon: '../../static/my/金币商城.png',
						text: ''
					}],
					num: ''
				}, {
					title: '积分',
					item: [{
						icon: '',
						text: '6000'
					}],
					num: ''
				}, ],
				finallyTab: [{
					title: '我的预约',
					icon: '../../static/my/金币商城.png',
					num: '10'
				}, {
					title: '会员卡',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '商城',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '我的订单',
					icon: '../../static/my/金币商城.png',
					num: '10'
				}, {
					title: '我的评论',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '个人档案',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '收货地址',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '关于我们',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '积分商城',
					icon: '../../static/my/金币商城.png',
					num: ''
				}, {
					title: '在线课和',
					icon: '../../static/my/金币商城.png',
					num: ''
				}],
				goPage(i) {
					console.log(i)
					switch (i) {
						case 0:
							uni.navigateTo({
								url: 'ChildrenPage/MyReservation'
							})
							break;
						case 1:
							uni.navigateTo({
								url: 'ChildrenPage/MyPersonalTrain'
							})
							break;
						case 2:
							uni.switchTab({
								url: '../News/News'
							})
							break;
						case 3:
							uni.navigateTo({
								url: 'comment/comment'
							})
							break;
						case 4:
							uni.navigateTo({
								url: '../jifen/jifen'
							})
							break;
					}
				},
				gotoPage(i) {
					console.log(i)
					switch (i) {
						case 1:
							uni.navigateTo({
								url: '../Client/Client'
							})
							break;
						case 2:
							uni.navigateTo({
								url: '../Mall/Mall'
							})
							break;
						case 3:
							uni.navigateTo({
								url: '/pages/My/ChildrenPage/MyOrder'
							})
							break;
						case 5:
							uni.navigateTo({
								url: 'ChildrenPage/Personal'
							})
							break;
						case 6:
							uni.navigateTo({
								url: 'HarvestAddress/HarvestAddress'
							})
							break;
					}
				},
				toPersonal() {
					uni.navigateTo({
						url: 'ChildrenPage/Personal'
					})
				}
			})
			let userInfo = reactive({
				nickName: '用户名',
				avatar: store.state.userdata[0].vipavatar,
				vipLevel: '一般会员'
			})
			onShow(()=>{
				console.log(store.state.userdata[0])
				userInfo.nickName = store.state.userdata[0].vipName
				userInfo.avatar = store.state.userdata[0].vipavatar
				switch(store.state.userdata[0].vipLevel){
					case 1:userInfo.vipLevel = '一般会员';
					break;
					case 2 :userInfo.vipLevel = '白银会员';
					break;
					case 3 :userInfo.vipLevel = '黄金会员';
					break;
					case 4 :userInfo.vipLevel = '钻石会员';
					break;
				}
			})
			return {
				userInfo,
				...toRefs(data)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.my-content {
		background-color: #F2F2F2;
		padding: 30rpx 25rpx;
		height: 100vh;
	}

	.my-head {
		display: flex;
		padding: 25rpx 20rpx;
		background-color: #FFFFFF;
		border-radius: 10px;
		justify-content: space-between;
		align-items: center;

		>view:nth-of-type(1) {
			width: 80rpx;
			height: 80rpx;
			border-radius: 5px;
			overflow: hidden;

			>image {
				width: 100%;
				height: 100%;
			}
		}

		>view:nth-of-type(2) {
			display: flex;
			flex-direction: column;
			flex-basis: 400rpx;

			>view:nth-of-type(1) {
				font-size: 35rpx;
				font-weight: bold;
			}

			>view:nth-of-type(2) {
				border-radius: 20rpx;
				background: linear-gradient(to right, #007DFE, #00C0FF);
				text-align: center;
				font-size: 26rpx;
				font-weight: bold;
				margin-top: 10rpx;
				padding: 10rpx, 5rpx;
				width: 150rpx;
				color: #FFFFFF;
			}
		}
	}

	.tab-scend {
		margin: 20rpx 0;
		padding: 50rpx 40rpx;
		background-color: #FFFFFF;
		border-radius: 10px;
		display: flex;
		justify-content: space-between;
	}

	.item-box {
		display: flex;
		flex-direction: column;
		align-items: center;
		color: #999999;
		font-size: 28rpx;

		image {
			width: 40rpx;
			height: 40rpx;
		}
	}

	.finally-tab {
		margin: 20rpx 0;
		padding: 60rpx 50rpx;
		height: 450rpx;
		background-color: #FFFFFF;
		border-radius: 10px;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		align-content: space-between;

		&::after {
			content: '';
			flex: auto;
		}
	}

	.finitem {
		width: 70px;
		margin-right: 5px;
	}
</style>
